# -*-* encoding:UTF-8 -*-
# author            : mengy
# date              : 2018/12/13
# python-version    : Python 3.7.0
# description       : 图形验证码破解

from PIL import Image

img = Image.open('wm.gif')
# 将图片转换成8位像素图
img.convert("P")

# 打印颜色直方图
histogram = img.histogram()
print(histogram)

# values = list([histogram[i] for i in range(256)])
values = {}
for i in range(256):
    values[i] = histogram[i]

for i,j in sorted(values.items(),key=lambda x:x[1],reverse = True)[:10]:
    print(i,j)
# print(values)